<?php

/* 会员 buyer */
class SpecialModel extends BaseModel
{
    var $table  = 'special_made';
    var $prikey = 'special_id';
    var $_name  = 'special';
	
	
    var $_relation = array(
		'has_sample' => array(
			'model' => 'sample',
			'type' => HAS_MANY,
			'foreign_key' => 'special_id',
			'dependent' => true,
		),
	);

    /*
     * 判断名称是否唯一
     */
    function unique($special_name, $special_id = 0)
    {
        $conditions = "special_name = '" . $special_name . "'";
        $special_id && $conditions .= " AND special_id <> '" . $special_id . "'";
        return count($this->find(array('conditions' => $conditions))) == 0;
    }
}

?>